package cn.tedu.lbs.marketing.web.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * 创建 spring容器中 CompletableFuture使用的线程池bean对象
 */
@Configuration
public class ThreadPoolConfig {
    @Bean("myThreadPool")
    public ThreadPoolTaskExecutor initMyThreadPool(){
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(10);
        executor.setMaxPoolSize(20);
        executor.setQueueCapacity(100);
        executor.setThreadNamePrefix("myThreadPool-");
        executor.initialize();
        return executor;
    }
}
